/*

Frequency of use: 1 2 3 [4] 5 MEDIUM HIGH

Short:
    Proxy allows one object to stand for something else.  So whilst you think 
you are dealing with one object, you are actually dealing with something else.  
In this example, CoutProxy stands for std::cout.

Long:
    A proxy, in its most general form, is a class functioning as an interface to 
something else. The proxy could interface to anything: a network connection, a 
large object in memory, a file, or some other resource that is expensive or 
impossible to duplicate.
A well-known example of the proxy pattern is a reference counting pointer 
object.
In situations where multiple copies of a complex object must exist the proxy 
pattern can be adapted to incorporate the flyweight pattern in order to reduce 
the application's memory footprint. Typically one instance of the complex object 
is created, and multiple proxy objects are created, all of which contain a 
reference to the single original complex object. Any operations performed on the 
proxies are forwarded to the original object. Once all instances of the proxy 
are out of scope, the complex object's memory may be deallocated.

Information sources:
 - http://calumgrant.net/patterns/index.html
 - http://en.wikipedia.org/wiki/Proxy_pattern
 - http://www.dofactory.com/Patterns/Patterns.aspx
*/

#include <iostream>
#include <string>

class CoutProxy
{
public:
	void write(const std::string & str) const
	{
		std::cout << str;
	}
};

void hello_world(const CoutProxy & cout)
{
	cout.write("Hello world!\n");
}

int main()
{
	hello_world(CoutProxy());
	return 0;
}

